<%--
  Created by IntelliJ IDEA.
  User: ZT
  Date: 2022-2-26 0026
  Time: 下午 3:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<link rel="stylesheet" href="/js/layui/css/layui.css">
<script src="/js/layui/layui.js"></script>
<body>
<br>
<form class="layui-form" action="" id="frm">
    <div class="layui-form-item">
        <label class="layui-form-label">编号</label>
        <div class="layui-input-inline">
            <input type="text" name="id" required  lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="text" name="pwd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话号码</label>
        <div class="layui-input-inline">
            <input type="text" name="number" required lay-verify="required" placeholder="请输入电话号码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账户状态</label>
        <div class="layui-input-inline">
            <input type="text" name="state" required lay-verify="required" placeholder="请输入用户状态" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    //Demo
    layui.use(['form','jquery','layer'], function(){
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;
        //监听提交
        form.on('submit(formDemo)', function(data){

            $.post("../user?method=update",$("#frm").serialize(),function () {
                //提示修改成功
                layer.msg("操作成功！",{
                    title:"提示",
                    icon:1
                });
                //重新加载最新数据
                //关闭弹出层
                setTimeout(function () {
                    //弹出层的父窗口刷新即可
                    window.parent.location.reload();
                },2000);
            });
            //不提交，因为表单(action)提交会刷新
            return false;
        });
    });
</script>
</body>
</html>
